package Demo01;
interface IMessage extends AutoCloseable
{
    public void send(String msg);
}
class NetMessage implements IMessage{
    public NetMessage(){
        System.out.println("【连接远程服务器，创建消息的发送通道...】");
    }
    @Override
    public void send(String msg)
    {
        System.out.println("【发送】" + msg);
    }
    public void close()
    {
        System.out.println("【关闭】网络消息发送完毕，断开服务器连接...");
    }
}

public class AutoCloseable05 {
    public static void main(String[] args) throws Exception
    {
        try (NetMessage message = new NetMessage()) {
            message.send("沐言科技：www.yootk.com");
        } catch (Exception e) {}
    }
}
